﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    public class Ship : Sprite
    {
        private Vector2 MovingVector;

        private float RotationAngle;
        private float zoom;
        

        public Ship() : base()
        {
            RotationAngle = 0;
        }

        public override void HandleInput(KeyboardState myKeyBoard, MouseState myMouseState, Rectangle myScreen)
        {
            if( myKeyBoard.IsKeyDown(Keys.Down) ){
                MovingVector = base.MyPosition;
                MovingVector.Y = MovingVector.Y + 2;
                
                if (MovingVector.Y + base.MyTexture.Height / 2 >= myScreen.Height)
                {
                    MovingVector.Y = myScreen.Height - base.MyTexture.Height / 2;
                }

                base.MyPosition = MovingVector;
            }

            if( myKeyBoard.IsKeyDown(Keys.Up) ){
                MovingVector = base.MyPosition;
                MovingVector.Y = MovingVector.Y - 2;
                
                if(MovingVector.Y <= Vector2.Zero.Y + base.MyTexture.Height / 2)
                {
                    MovingVector.Y = Vector2.Zero.Y + base.MyTexture.Height / 2;
                }
                
                base.MyPosition = MovingVector;
            }
        }


        public override void Initialize()
        {
            base.MyPosition = new Vector2(27, 30);
        }

        public override void Draw(SpriteBatch mySpriteBatch, GameTime myGameTime, Rectangle myScreen)
        {

            RotationAngle += 0.1f;
            if(RotationAngle % 0.02f == 0)
            {
                zoom = 0.9f;
            }
            else
            {
                zoom = 1.2f;
            }
            mySpriteBatch.Draw(base.MyTexture, base.MyPosition, null, Color.White, RotationAngle, new Vector2(base.MyTexture.Width / 2, base.MyTexture.Height / 2),zoom,SpriteEffects.None,0);
        }

    }
}

